package com.euq.mapper;

import com.euq.entity.Dict;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DictMapper {
    @Select("select * from dict")
    List<Dict> list();
    @Select("select * from dict where name =#{name}")
    List<Dict> getDictByName(String name);
    @Delete("delete from dict where id =#{id}")
    void deleteById(int id);
    @Delete("delete from dict where pid =#{pid}")
    void deleteByPid(Long pid);
    @Select("SELECT * FROM dict WHERE name = #{name} AND pid = #{pid}")
    Dict findByNameAndPid(@Param("name") String name, @Param("pid") Long pid);
    @Insert("INSERT INTO dict(create_by,create_time,modify_by,modify_time,name, tips, num, pid) VALUES(1,now(),1,now(),#{name}, #{tips}, #{num}, #{pid})")
    @Options(useGeneratedKeys = true, keyProperty = "id")  // 自动生成主键
    int insertDict(Dict dict);
}
